import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img=cv.imread("G:\\Learn\\CSDN\\Work\\lena.jpg",0)
source=cv.Canny(img,50,150)

titles=['SourceImage','EdgeImage']
images=[img,source]
for i in range(2):
    plt.subplot(1, 3, i + 1), plt.imshow(images[i], 'gray')
    plt.title(titles[i])
    plt.xticks([]), plt.yticks([])
plt.show()

cv.waitKey(0)
cv.destroyAllWindows()


'''
img=cv.imread("G:\\Learn\\CSDN\\Work\\lena.jpg",0)
x=cv.Sobel(img,cv.CV_16S,1,0)
y=cv.Sobel(img,cv.CV_16S,0,1)

absX=cv.convertScaleAbs(x)
absY=cv.convertScaleAbs(y)

dst=cv.addWeighted(absX,0.5,absY,0.5,0)

titles=['XEdgeImage','YEdgeImage','EdgeImage']
images=[absX,absY,dst]
for i in range(3):
    plt.subplot(1, 3, i + 1), plt.imshow(images[i], 'gray')
    plt.title(titles[i])
    plt.xticks([]), plt.yticks([])
plt.show()
'''
'''
cv.imshow("absX",absX)
cv.imshow("absY",absY)
cv.imshow("Result",dst)

cv.waitKey(0)
cv.destroyAllWindows()
'''

